Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: ASRC: Code reorganization #8514

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Conversation

andrula-song
Copy link
Contributor

  1. Move all ASRC related header files into src/audio/asrc folder.
  2. split IPC version related code to asrc_ipc3.c and asrc_ipc4.c.

@keqiaozhang
Copy link
Collaborator

SOFCI TEST

Copy link
Collaborator

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/audio/CMakeLists.txt Outdated Show resolved Hide resolved
src/audio/asrc/asrc.c Show resolved Hide resolved
src/audio/asrc/asrc.c Outdated Show resolved Hide resolved
src/audio/asrc/asrc.c Outdated Show resolved Hide resolved
src/audio/asrc/asrc.c Outdated Show resolved Hide resolved
src/audio/asrc/asrc.c Outdated Show resolved Hide resolved
src/audio/asrc/asrc.h Show resolved Hide resolved
@andrula-song andrula-song changed the title Audio: ASRC: Code clean Audio: ASRC: Code reorganization Nov 24, 2023
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make the Cmake/Kconfig changes later as there are other PRs that need to be merged 1st.

@@ -174,12 +174,14 @@ set(sof_audio_modules mixer volume src asrc eq-fir eq-iir dcblock crossover tdfb
# sources for each module
if(CONFIG_IPC_MAJOR_3)
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc3.c)
set(asrc_sources asrc/asrc_ipc3.c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu @andrula-song @btian1 These should really be in src/audio/module_name/CMakefile.txt (same rule applies to Kconfig too)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, shall we use a separate pr to do the clean up once we finished all module converter.
this is because the in-complete of Cmakelist in module, some does not have, some does not used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgirdwood , this change is based on search, so I request use a separate PR to track clean up src/audio/cMakeList.txt

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, "asrc_sources" was not set before this PR, so why do it now. It seems we already go to the asrc subdirectory, so I don't see why we need to add individual source files here.

Copy link
Contributor Author

@andrula-song andrula-song Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, it is first set in line 196 as "set(asrc_sources asrc/asrc.c asrc/asrc_farrow.c asrc/asrc_farrow_generic.c)". Adding here is just to keep the asrc_sources right after I refine ASRC code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack @andrula-song . I still don't understand why we set the module sources list twice, but clearly this was not added in this PR, so should not block this one. Let's handle separately.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why we set the module sources list twice,

Same "LIBRARY" explanation as in #8595 (comment), isn't it?

@andrula-song
Copy link
Contributor Author

SOFCI TEST

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, needs the cleanups in a different patch.

src/audio/asrc/asrc.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it much better with the typedef!

src/audio/asrc/asrc_ipc4.c Outdated Show resolved Hide resolved
zephyr/CMakeLists.txt Outdated Show resolved Hide resolved
btian1

This comment was marked as outdated.

Copy link
Collaborator

@RanderWang RanderWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to move it to ASRC folder ? Thanks!

@keqiaozhang
Copy link
Collaborator

SOFCI TEST

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good here.

#else
const struct ipc4_asrc_module_cfg *ipc_asrc = mod_data->cfg.init_data;
#endif
const ipc_asrc_cfg *ipc_asrc = mod_data->cfg.init_data;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a code change (I know, no impact), but should come in another patch.

asrc_proc_func asrc_func; /* ASRC processing function */
};

#ifndef CONFIG_IPC_MAJOR_4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now. We can incrementally update if needed.

#ifdef CONFIG_IPC_MAJOR_4
typedef struct ipc4_asrc_module_cfg ipc_asrc_cfg;
#else
typedef struct ipc_config_asrc ipc_asrc_cfg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for now, we can split this further later if needed.

zephyr/CMakeLists.txt Outdated Show resolved Hide resolved
src/audio/asrc/asrc.h Show resolved Hide resolved
@marc-hb
Copy link
Collaborator

marc-hb commented Dec 4, 2023

@btian1
Copy link
Contributor

btian1 commented Dec 6, 2023

@lyakh , with typedef, there are codestyle errors, do you still insist use typedef, how about #define, or directly use # if IPC3?

@lyakh
Copy link
Collaborator

lyakh commented Dec 6, 2023

@lyakh , with typedef, there are codestyle errors, do you still insist use typedef, how about #define, or directly use # if IPC3?

@btian1 I never insisted on that, it was my proposal. I still think it's ok to ignore code style complaints in this case, but if others disagree we can also use a #define which would be my second preference.

@@ -16,7 +16,7 @@
#if defined __XCC__
/* For xt-xcc */
#include <xtensa/config/core-isa.h>
#if XCHAL_HAVE_HIFI3 == 1
#if XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't really a code reorganization... It's really not good practice to add such configuration changes in the middle or a code move...

This should be in a separate patch IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a separate commit at last.

@marc-hb
Copy link
Collaborator

marc-hb commented Dec 6, 2023

but if others disagree we can also use a #define which would be my second preference.

Checkpatch is not always right: https://www.kernel.org/doc/html/latest/dev-tools/checkpatch.html

Checkpatch is not always right. Your judgement takes precedence over checkpatch messages. If your code looks better with the violations, then its probably best left alone.

I wish people obsessed at least as much about actual test results as about checkpatch. "Do not add any new typedef" looks especially wrong. Maybe it makes sense in the Linux kernel but not here. The less pre-processing the better; the indirection is a nightmare to debug (recent example: zephyrproject-rtos/zephyr#65953)

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly look good, a few minor comments inline.

@@ -174,12 +174,14 @@ set(sof_audio_modules mixer volume src asrc eq-fir eq-iir dcblock crossover tdfb
# sources for each module
if(CONFIG_IPC_MAJOR_3)
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc3.c)
set(asrc_sources asrc/asrc_ipc3.c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, "asrc_sources" was not set before this PR, so why do it now. It seems we already go to the asrc subdirectory, so I don't see why we need to add individual source files here.

src/audio/asrc/CMakeLists.txt Show resolved Hide resolved

void asrc_update_buffer_format(struct comp_buffer *buf_c, struct comp_data *cd)
{
//IPC3 don't need to update audio stream format here.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-style comments would be better


void asrc_set_stream_params(struct comp_data *cd, struct sof_ipc_stream_params *params)
{
//IPC3 don't need to set audio stream params here.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here

Move the ASRC related header files into ASRC folder.

Signed-off-by: Andrula Song <[email protected]>
Use typedef ipc_asrc_cfg to replace the splited IPC version
asrc module config structure.

Signed-off-by: Andrula Song <[email protected]>
Move IPC3 related code to asrc_ipc3.c and IPC4 related code
to asrc_ipc4.c.

Signed-off-by: Andrula Song <[email protected]>
Make HiFi4 share c source files with HiFi3.

Signed-off-by: Andrula Song <[email protected]>
Copy link
Collaborator

@singalsu singalsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! With assumption Kai's findings fixed.

@@ -174,12 +174,14 @@ set(sof_audio_modules mixer volume src asrc eq-fir eq-iir dcblock crossover tdfb
# sources for each module
if(CONFIG_IPC_MAJOR_3)
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc3.c)
set(asrc_sources asrc/asrc_ipc3.c)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack @andrula-song . I still don't understand why we set the module sources list twice, but clearly this was not added in this PR, so should not block this one. Let's handle separately.

@kv2019i kv2019i merged commit bfb6780 into thesofproject:main Dec 11, 2023
40 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants